<template>
	<div class="container">
		<div class="input-group mb-3">
		  <input v-model="searchUser" type="text" class="form-control" placeholder="输入用户名" aria-label="Recipient's username" aria-describedby="button-addon2">
		  <button @click="searchUsers" class="btn btn-outline-secondary" type="button" id="button-addon2">Button</button>
		</div>
	</div>
</template>

<script>
	import axios from 'axios'
	export default{
		data(){
			return{
				searchUser:""
			}
		},
		methods:{
			searchUsers(){
				axios.get(`https://api.github.com/search/users?q=${this.searchUser}`).then((response)=>{
						this.$bus.$emit("searchResult",response.data.items)
						console.log(response.data.items)
				      }).catch((response)=>{
				        console.log(response);
				      })
			}
		}
	}
</script>

<style>
	.container{
		padding: 5%;
	}
</style>